function objGrad ()
% Define objective function and its gradient
%
global Pgen_cut Pld_cut               % by initial.m   
global prob nlp                       % nlp is modified

nlp.func.objective = @objectiveFunc;
nlp.func.gradient = @gradientFunc;

global objScale
objScale = 100;
%% functions
    % f(x) = uG * Pgen_cut + uL * Pld_cut
    function f = objectiveFunc (x)
        uG = x(nlp.uGidx); uL = x(nlp.uLidx);
        f = objScale * feval(prob.objfun, uG, uL);
    end
    function g = gradientFunc (~)     % free from x
        g = sparse(nlp.nvar, 1);
        g(nlp.uGidx) = Pgen_cut; g(nlp.uLidx) = Pld_cut;
        g = objScale * g;
    end
end